/*
 * Copyright 2022-2023 Advanced Micro Devices Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#pragma once
#include <vector>
#include <sys/stat.h>
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>

#include "vitis/ai/medicaldetection.hpp"

using namespace cv;
using namespace std;

Scalar colors[] = { Scalar(255, 0, 0), Scalar(0, 255, 0), Scalar(0, 0, 255), Scalar(255, 0, 255), Scalar(0, 255, 255)};
std::vector<std::string> classTypes =  {"BE", "cancer", "HGD" , "polyp", "suspicious"};

std::string filenamepart1 = "testfile";

static cv::Mat process_result(cv::Mat &img,
                              const vitis::ai::MedicalDetectionResult &result,
                              bool is_jpeg) {

  for(auto& res: result.bboxes) {
     LOG_IF(INFO, is_jpeg)  << "RESULT: " 
               << classTypes[res.label-1] << "   "
               << res.score << "   "
               << res.x*img.cols << " "
               << res.y*img.rows << " "
               << (res.x+res.width)*img.cols << " "
               << (res.y+res.height)*img.rows << "\n";
     cv::rectangle(img, Point(res.x*img.cols, res.y*img.rows), Point((res.x+res.width)*img.cols, (res.y+res.height)*img.rows),  colors[res.label-1], 1, 1, 0);
  }
  return img;
}
